home *** CD-ROM | disk | FTP | other *** search
/ The CDPD Public Domain Collection for CDTV 4 / CDPD_IV.bin / e / mailinglists / amigae.0294feb.archive / 000046_donews!crash!ts…c.EDU!usr1400a_Sat, 12 Feb 94 01:42:21 PST.msg < prev    next >
Internet Message Format  |  1994-05-26  |  2KB

  1. Received: by bkhouse.cts.com (V1.17-beta/Amiga)
  2.       id <1t8c@bkhouse.cts.com>; Sat, 12 Feb 94 01:42:21 PST
  3. Received: from crash by donews.cts.com with uucp
  4.     (Smail3.1.28.1 #18) id m0pVBYw-0001OsC; Fri, 11 Feb 94 23:02 EST
  5. Received: from ROLL.SAN.UC.EDU by crash.cts.com with smtp
  6.     (Smail3.1.28.1 #18) id m0pVBLC-00003jC; Fri, 11 Feb 94 19:48 PST
  7. Received: from tso.uc.edu by UCBEH.SAN.UC.EDU (PMDF V4.2-14 #4918) id
  8.  <01H8RY2GR8WW924V2N@UCBEH.SAN.UC.EDU>; Fri, 11 Feb 1994 22:46:20 EST
  9. Received: by tso.uc.edu (4.1/SMI-4.1) id AA08956; Fri, 11 Feb 94 22:46:52 EST
  10. Date: Fri, 11 Feb 1994 22:46:52 -0500 (EST)
  11. Message-id: <9402120346.AA08956@tso.uc.edu>
  12. Content-transfer-encoding: 7BIT
  13. From: usr1400a@tso.uc.EDU (Carl Jolley)
  14. To: amigae@bkhouse.cts.COM
  15. Subject: Re: Bugs in the Mod() function
  16.  
  17. Bernie, In your message you said (in part):
  18.  
  19. > After a lot of debugging of code that ought to have worked, I
  20. > discovered that the Mod function seems to be VERY broken.  As we
  21. > [ought to] all know, taking an integer mod N should *always* get you
  22. > an integer between 0 and n-1.  Well, it ain't so in E.  A simple
  23. > test reveals:
  24. >
  25. > Modulo: Mod(11,8) = 3
  26. > Modulo: Mod(6,8) = 6
  27. > Modulo: Mod(1,8) = 1
  28. > Modulo: Mod(-4,8) = -4
  29. > Modulo: Mod(-9,8) = -1
  30. > Modulo: Mod(-14,8) = -6
  31. >
  32. > Which is clearly broken.  In the course of pursuing this, I discovered
  33. > that simple division ain't a prize, either:
  34. >
  35. > Dividing 11 / 8 = 1
  36. > Dividing 6 / 8 = 0
  37. > Dividing 1 / 8 = 0
  38. > Dividing -4 / 8 = 0
  39. > Dividing -9 / 8 = -1
  40. > Dividing -14 / 8 = -1
  41. >
  42. > It is astounding to me to try to understand arithmetic in an environment
  43. > where:
  44. >
  45. >     (A - B) / B  does *NOT* equal (A / B) - 1
  46.  
  47. Hmm, Bernie, I'm not sure what the last equation (or non-equation) has to
  48. to do your assertion that the Mod function is broken. As I recall (it's been
  49. a long time since I got my degree in Math) the Mod function involves the
  50. sign of the division operation being applied to the absolute value of the
  51. result. In any event, I've always used a a working definition of Mod to
  52. be the remainder after integral division. It seems correct to me as does
  53. the example "integer" division examples.